package com.zkzx.operation.api.controller.order;


import com.zkzx.common.freight.model.OrderListVO;
import com.zkzx.common.freight.model.OrderVO;
import com.zkzx.common.freight.param.OrderFilterParam;
import com.zkzx.common.vo.PageResult;
import com.zkzx.common.vo.RequestFilterParams;
import com.zkzx.operation.api.controller.BaseController;
import com.zkzx.operation.api.service.order.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author young Email:yanghui@zkraising.com
 * @description
 * @company 北京中科智兴物联科技有限公司 @版权所有
 * @since 2021年05月10日 17时46分
 */
@RestController
@Validated
@Api( tags="订单管理")
@RequestMapping(value = "/orders")
public class OrderController extends BaseController {

    @Autowired
    private OrderService orderService;

    @GetMapping
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "获取订单列表", notes = "获取订单列表")
    public PageResult<OrderListVO> find(@ApiParam(value = "查询参数") OrderFilterParam filterParam,
                                        @ApiParam(value = "分页查询参数") RequestFilterParams params)  {
          //企业信息，车辆和司机去API接口组装
        return orderService.find(filterParam,params,super.getUserId());
    }

    @GetMapping("/{id}")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "获取订单详细", notes = "获取订单详细")
    public OrderVO getById(@PathVariable("id") Integer id) {
        return orderService.getById(id,super.getUserId());
    }

}
